package com.masterclient.app.base;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.masterclient.app.R;
import com.eoner.baselibrary.utils.ScreenUtils;


public class CashTakePhotoDialog extends Dialog{

    public CashTakePhotoDialog(@NonNull Context context) {
        super(context,R.style.MyDialog);
    }


    private TextView take_photo,select_img,cancel;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_cash_take_photo);
        take_photo = (TextView) findViewById(R.id.take_photo);
        select_img = (TextView) findViewById(R.id.select_img);
        cancel = (TextView) findViewById(R.id.cancel);


        take_photo.setOnClickListener(v->{
            if(onChooseListerner!=null){
                onChooseListerner.take_photo();
            }
        });
        select_img.setOnClickListener(v->{
            if(onChooseListerner!=null){
                onChooseListerner.select_photo();
            }
        });
        cancel.setOnClickListener(v->{
            if(onChooseListerner!=null){
                onChooseListerner.cancel();
            }
        });

    }


    @Override
    protected void onStart() {
        super.onStart();
        Window window = getWindow();
        WindowManager.LayoutParams windowparams = window.getAttributes();
        windowparams.width = ScreenUtils.getScreenWidth();
        window.setGravity(Gravity.BOTTOM);
        window.setBackgroundDrawableResource(android.R.color.transparent);
        window.setAttributes(windowparams);
    }

    public void setOnChooseListerner(OnChooseListerner onChooseListerner) {
        this.onChooseListerner = onChooseListerner;
    }

    private OnChooseListerner onChooseListerner;

    public interface OnChooseListerner{
        public void cancel();
        public void take_photo();
        public void select_photo();
    }
}
